package net.aiotos.common.dto;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;


/**
 * 标准config属性对象结构（用户可自定义）
 * 下面字段为标准自带字段,不可删除
 */
@Data
@NoArgsConstructor
public class DataConfigDTO {

    /**
     * equation : null
     * param : {}
     * disabled : false
     * proxy : {"index":"","pointer":null}
     * parentId : 33dd
     * position : []
     * class : null
     */

    @JSONField(name = "equation")
    private Object equation;
    @JSONField(name = "param")
    private JSONObject param;
    @JSONField(name = "disabled")
    private Boolean disabled;
    @JSONField(name = "proxy")
    private ProxyDTO proxy;
    @JSONField(name = "parentId")
    private String parentId;
    @JSONField(name = "class")
    private Object classX;
    @JSONField(name = "position")
    private List<?> position;


    @NoArgsConstructor
    @Data
    public static class ParamDTO extends JSON {
    }

    @NoArgsConstructor
    @Data
    public static class ProxyDTO extends JSON {
        private String pointer;
        private Short index;
    }

    public <T> T getParam(Class<T> tClass) {
        return param.toJavaObject(tClass);
    }
}
